package com.lc.user.express.httpserver;

import com.lc.user.express.model.MyStardModel;
import com.lc.user.express.model.MyStardtextModel;
import com.lc.user.express.model.MyStardandModel;
import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.http.note.HttpInlet;

import org.json.JSONArray;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/4/1.收费标准
 */
@HttpInlet(Net.GET_STARDAND)
public class GetStardand extends ZJDBAsyGet<GetStardand.Info> {
    public String areaid;

    public GetStardand(String areaid, AsyCallBack<Info> asyCallBack) {
        super(asyCallBack);
        this.areaid = areaid;
    }

    @Override
    protected Info parser(JSONObject object) {
        if (object.optInt("message") == 1) {
            Info info = new Info();
            JSONArray array = object.optJSONArray("list");

            if (array != null) {
                for (int i = 0; i < array.length(); i++) {
                    JSONObject object1 = array.optJSONObject(i);
                    MyStardandModel myStardandModel = new MyStardandModel();
                    myStardandModel.setTv1_stardand_item(object1.optString("title"));
                    myStardandModel.setTv2_stardand_item(object1.optString("price"));
                    myStardandModel.setTv3_stardand_item(object1.optString("costs"));
                    info.list.add(myStardandModel);
                }
            }
            JSONArray array1 = object.optJSONArray("addlist");
            if (array1 != null) {
                for (int i = 0; i < array1.length(); i++) {
                    JSONObject object2 = array1.optJSONObject(i);
                    MyStardModel myStardModel = new MyStardModel();
                    myStardModel.setTv4_stardand_item(object2.optString("title"));
                    myStardModel.setTv5_stardand_item(object2.optString("info"));
                    info.addlist.add(myStardModel);
                }
            }
            JSONArray array2 = object.optJSONArray("infolist");
            if (array2 != null) {
                for (int i = 0; i < array2.length(); i++) {
                    JSONObject object3 = array2.optJSONObject(i);
                    MyStardtextModel myStard_text = new MyStardtextModel();
                    myStard_text.setText_list_stardand(object3.optString("title"));
                    info.infolist.add(myStard_text);
                }
            }


            return info;

        }
        return null;
    }

    public class Info {
        public List<MyStardModel> addlist = new ArrayList<>();
        public List<MyStardandModel> list = new ArrayList<>();
        public List<MyStardtextModel> infolist = new ArrayList<>();
    }
}
